import request from "@/utils/request";

function page(current, size, grade, majorName, name, departmentName) {
    return request({
        method: 'GET',
        url: '/class/page',
        params: {
            current: current,
            size: size,
            grade: grade,
            majorName: majorName,
            name: name,
            departmentName: departmentName,
        }
    });
}

function get_all() {
    return request({
        method: 'GET',
        url: '/class/list',
    });
}


function add(grade, name, majorId, studentCount, departmentId) {
    return request({
        method: 'POST',
        url: '/class',
        data: {
            grade: grade,
            name: name,
            majorId: majorId,
            studentCount: studentCount,
            departmentId: departmentId,
        }
    });
}

function edit(id, grade, name, majorId, studentCount, departmentId) {
    return request({
        method: 'PUT',
        url: '/class',
        data: {
            id: id,
            grade: grade,
            name: name,
            majorId: majorId,
            studentCount: studentCount,
            departmentId: departmentId,
        }
    });
}

function del(id) {
    return request({
        method: 'DELETE',
        url: `/class/${id}`,
    });
}

export default {
    page,
    get_all,
    add,
    edit,
    del,
}